<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>送货单设置</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-card layui-col-md12">
        <div class="layui-card-header"><i class="fa fa-cog"></i> 送货单设置</div>
        <div class="layui-card-body" pad15>
          <div class="layui-form form-label-w8" lay-filter="">
            <input type="hidden" name="info[id]" value="{$info['id']}">
            <div class="layui-form-item">
              <label class="layui-form-label">打印标题：</label>
              <div class="layui-input-inline">
                <input type="text" name="info[shipping_pagetitle]" class="layui-input" value="{$info['shipping_pagetitle']}">
              </div>
              <div class="layui-form-mid" >
                <div class="layui-popover layui-default-link layui-inline">
                  示例
                  <div class="layui-popover-div">
                    <img src="__STATIC__/admin/img/dianda_shd.png" style="width: 600px" />
                  </div>
                </div>
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">每页行数：</label>
              <div class="layui-input-inline">
                <input type="text" name="info[shipping_pagenum]" class="layui-input" value="{$info['shipping_pagenum']}">
              </div>
              <div class="layui-form-mid" >仅支持商城送货单，控制每页显示和打印行数（根据纸张大小修改），0为不限制</div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">品名及规格行数：</label>
              <div class="layui-input-inline">
                <input type="text" name="info[shipping_linenum]" class="layui-input" value="{$info['shipping_linenum']}">
              </div>
              <div class="layui-form-mid" >仅支持商城送货单，控制“品名及规格”文字显示几行，多出的用省略号表示，0为不限制</div>
            </div>
            {if getcustom('shd_print') ||  getcustom('shop_shd_print2')}
            <div class="layui-form-item">
              <label class="layui-form-label">批量打印金额：</label>
              <div class="layui-input-inline">
                <input type="radio" name="info[printmoney]" value="0" {if $info['printmoney']==0}checked{/if} title="隐藏"/>
                <input type="radio" name="info[printmoney]" value="1" {if $info['printmoney']==1}checked{/if} title="显示"/>
              </div>
              <div class="layui-form-mid" >仅支持商城送货单</div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">批量打印第几联：</label>
              <div class="layui-input-inline">
                <input type="radio" name="info[printlian]" value="0" {if $info['printlian']==0}checked{/if} title="隐藏"/>
                <input type="radio" name="info[printlian]" value="1" {if $info['printlian']==1}checked{/if} title="显示"/>
              </div>
              <div class="layui-form-mid">仅支持商城送货单</div>
            </div>
            {/if}
            <div class="layui-form-item">
              <label class="layui-form-label"></label>
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formsubmit">提 交</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  {include file="public/js"/}

  <script>
    var express_ldata = {$express_ldata?$express_ldata:"''"};
    var express_rdata = {$express_rdata?$express_rdata:"''"};
    layui.use(['transfer'], function(){
      var transfer = layui.transfer
      //显示搜索框
      transfer.render({
        elem: "#express_data",
        id:"express_right",
        data: express_ldata,
        value: express_rdata,
        title: ['系统快递', '自定义快递'],
        height:500,
        showSearch: true,
        onchange: function(obj, index){
          var getData = transfer.getData('express_right'); //获取右侧数据
          var len = getData.length;
          if(getData && len>0){
            var data = {};
            for(var i=0;i<len;i++){
              data[getData[i].title] = getData[i].value;
            }
            $('#express_datas').val(JSON.stringify(data));
          }else{
            $('#express_datas').val('');
          }
        }
      })
    });
    // 调用
    $('.videoMoveBtn').click(function () {
        transfornMove({
            elem: '#express_data',
            direction: $(this).data('direction')
        })
    });
    function transfornMove(option) {
        var rightTransforn   = $($(option.elem + " ul")[1])
        var checkItem        = rightTransforn.find('.layui-form-checked').parent()
        var rightTransBottom = rightTransforn.children()
        var checkOneIndex    = rightTransBottom.index(option.direction == 'down' ? checkItem[checkItem.length - 1] : checkItem[0])
        var rightDataLength  = rightTransBottom.length
        if (!checkItem.length) {
            layer.msg("请选择数据后再操作");
            return;
        }
        if (checkOneIndex == (option.direction == 'down' ? rightDataLength - 1 : 0)) {
            layer.msg("已是首位");
            return;
        }
        if (option.direction == 'down') {
            for (var i = checkItem.length; i >= 0; i--) {
                checkItem.eq(i).next().after(checkItem.eq(i));
            }
        } else {
            for (var i = 0; i < checkItem.length; i++) {
                checkItem.eq(i).prev().before(checkItem.eq(i));
            }
        }
        var getData = layui.transfer.getData('express_right'); //获取右侧数据
        var len = getData.length;
        if(getData && len>0){
          var data = {};
          for(var i=0;i<len;i++){
            data[getData[i].title] = getData[i].value;
          }
          $('#express_datas').val(JSON.stringify(data));
        }else{
          $('#express_datas').val('');
        }
    }
    layui.form.on('submit(formsubmit)', function(obj){
      var field = obj.field
      var index = layer.load();
      $.post("{:url('save')}",field,function(data){
        layer.close(index);
        dialog(data.msg,data.status);
      })
    })
  </script>
</body>
</html>